package com.example.task1.ui.user.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.OrderBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class OrderAdapter extends BaseAdapter<OrderBean.RowsDTO> {

    private Context context;
    private List<OrderBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvTitle;
    private TextView tvOrderNum;
    private TextView tvName;
    private TextView tvOrderStatus;

    @Override
    public void setData(List<OrderBean.RowsDTO> rows) {
        mData = rows;
        notifyDataSetChanged();
    }

    @Override
    protected int getLayout() {
        return R.layout.orderlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<OrderBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, OrderBean.RowsDTO date) {
        tvTitle.setText(date.getOrderTypeName());
        tvName.setText(date.getName());
        tvOrderStatus.setText(date.getOrderStatus());
        tvOrderNum.setText(date.getOrderNo());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        tvTitle = view.findViewById(R.id.tv_title);
        tvOrderNum = view.findViewById(R.id.tv_order_num);
        tvName = view.findViewById(R.id.tv_name);
        tvOrderStatus = view.findViewById(R.id.tv_order_status);
    }
}
